Skip to content

Conversation

henrygr
Copy link
Member

@henrygr henrygr commented Oct 29, 2026

Problem

The deploy workflow ran prisma db push, which syncs tables but never executes migration SQL. SQL-only migrations (the haversine_distance function) were therefore never applied, and no _prisma_migrations history was created. Any later prisma migrate deploy could not recover from that state, and the deployed database was left without the function.

Changes

  • Apply migrations on deploy: the workflow now runs pnpm db:deploy (prisma migrate deploy) instead of prisma db push.
  • Add a db:deploy script to the root and packages/db package scripts.
  • Add scripts/baseline-db.sh (pnpm db:baseline), a one-time bootstrap for databases that were created with db push. It marks schema migrations that are already reflected in the database as applied and leaves SQL-only migrations pending so migrate deploy runs them. It is idempotent and does nothing on an empty database or when migration history already exists.
  • Document migration-based deploys, the one-time baseline, and failed-migration recovery in the README.

Testing

  • pnpm typecheck
  • pnpm check
  • bash -n scripts/baseline-db.sh
  • Baseline script verified against four database states: push-managed without the function, push-managed with the function already created, empty database, and a database with existing migration history.
  • The same repair sequence was run against the deployed database on the VM: prisma migrate deploy applied add_reviews, the database was seeded, and the nearby/venue GraphQL queries (including reviews) return data again.

@henrygr henrygr requested a review from a team as a code owner October 29, 2026 14:14
@henrygr henrygr self-assigned this Oct 29, 2026
Copy link
Member

@sivertlv sivertlv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the PRs of all time

@henrygr henrygr merged commit 449d97d into main Oct 29, 2026
1 check passed
@henrygr henrygr deleted the fix/automatic-deployment branch October 29, 2026 14:19
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants